#include <ctime>
#include <math.h> 
#include <cstdlib> 
#include <iostream>
#include <Windows.h>
#include <conio.h>

using namespace std;
int main()
{
	char c = 'Y';

	while (1) 
	{
		system("cls");
		char ChuoiConst[37] = "2YOPB3AQCVUXMNRS97WE0IZD4KLFGHJ8165T";
		int nSoChia[4] = {43, 23, 17, 53};

		srand(time(0));

		int a = rand() % 36; 
		int b = rand() % 36;
		int c = rand() % 36;
		int d = 0, e = 0;

		cout << "Console APP: IDM Key Maker" << endl << endl;
		cout << "Key: ";
		for ( int i = 0 ; i < 4 ; i++)
		{
			do
			{
				d = rand() % 36;
				e = rand() % 36;
			}
			while (((((a*37 + b)*37 + c)*37 + d)*37 + e) % nSoChia[i] != 0);

			cout <<ChuoiConst[a] << ChuoiConst[b] << ChuoiConst[c] << ChuoiConst[d] << ChuoiConst[e] << ((i == 3) ? "":"-");
		}

		cout << "\n\n_/_/_/_/_/_/_/_/_/_/_/_/_/_ NOTICE _/_/_/_/_/_/_/_/_/_/_/_/_/\n\nAdd these lines to file host <C:/Windows/System32/driver/etc/hosts>:" << endl;
		cout << "\n127.0.0.1 www.internetdownloadmanager.com" << endl;
		cout << "127.0.0.1 registeridm.com\n" << endl;

		cout << "_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/" << endl << endl;
		cout << "Do you want to re-make IDM key? Y/N? ";

		c = getch();
		cout << (char)c;

		if (c == 'n' || c == 'N') break;
	} 

	cout << endl;
	cin.get();
	return 0;
}